#ifndef ASSEMBLER_H
#define ASSEMBLER_H
//Author: Austen Higgins-Cassidy
// 4/10/2012
#include "extractor.h"
#include <map>
#include <vector>

#define dimsize(x) (sizeof(x)/(sizeof(x[0])))
#define OP_OP 0x001F
#define OP_B 0x03E0
#define OP_A 0xFC00

unsigned short map_op(std::string &tok);
unsigned short map_nonbasic(std::string &tok);

struct inst {
	unsigned short op;
	unsigned short a;
	unsigned short b;
};


unsigned short map(std::string &buf, inst *i, std::vector<std::pair<std::string, unsigned short*>> *lct);
unsigned short map_val(std::string tok, unsigned short *word, std::vector<std::pair<std::string, unsigned short*>> *lct );

void WriteHex(std::ostream &out, const unsigned short &word);

void assemble(std::istream &in, std::ostream &out);
void assemble(std::istream &in, std::ostream &out, unsigned short *&bin, unsigned short &size);
void writeBin(unsigned short size, unsigned short *bin, std::ostream &out);
#endif